package kiwi.core.services.search.solr.program.parser.model;

import kiwi.core.api.triplestore.ResourceService;
import kiwi.core.api.triplestore.TripleStore;
import kiwi.core.model.rdf.KiWiResource;
import org.apache.solr.common.SolrInputDocument;

import java.util.List;

/**
 * User: Thomas Kurz
 * Date: 25.03.11
 * Time: 14:14
 */
public class Rule {

	private String name;
	private Path path;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getInternalName() {
		return path.getTypePrefix()+"_"+name;
	}

	public Path getPath() {
		return path;
	}

	public void setPath(Path path) {
		this.path = path;
	}

	public String toString() {
		return name+" = "+path+";";
	}

	public void apply(TripleStore triplestore, KiWiResource r, ResourceService resourceService, SolrInputDocument doc) {
		List<String> l = path.getValue(triplestore,r,resourceService);
		doc.addField(getInternalName(),l);
	}

}
